/**
* @Description: WoShop商城
* @Author: 梧桐
* @Copyright: 武汉一一零七科技有限公司©版权所有
* @Link: www.wo-shop.net
* @Contact: QQ:2487937004
*/
<template>
	<view class="page">
		<u-steps class="u-m-" :list="numList" :current="Number(applys.zhuangtai)-1" mode="number"
			active-color="#ffc107"></u-steps>
		<view class="settled u-p-25" v-if="applys.zhuangtai == 6">
			<p>{{$t('拒绝原因')}}:{{applys.remarks}}</p>
			<u-button type="warning" @click="$u.route('/pagesC/applyshop/applyType')">{{$t('重新申请入驻')}}</u-button>
		</view>
		<p class="u-p-25">{{applys.xinxi}}</p>
		<u-cell-group v-if="applys.zhuangtai == 3 && applys.shop_is_earnest == 1">
			<u-cell-item :title="$t('您申请的行业为')" :value="industrys.industry_name" :arrow="false"></u-cell-item>
			<u-cell-item :title="$t('费率')" :value="industrys.remind /100 +'%'" :arrow="false"></u-cell-item>
			<u-cell-item :title="$t('缴纳的保证金')" :value="'¥'+industrys.ser_price" :arrow="false"></u-cell-item>
			<u-button class="u-m-20" @click="openPayPop" type="warning">{{$t('缴纳保证金')}}</u-button>
		</u-cell-group>
		<p class="u-p-25" style="color:#999">{{$t('如果状态未能实时变更，可下拉刷新获取实时信息变更')}}</p>
		<!--收银台组件-->
		<payPop ref="payPop" :totalPrice="industrys.ser_price" scene="recharge">
			<div class="pay-btn" @click="$u.debounce(crosspay,1500)">{{$t('确认支付')}}</div>
		</payPop>
	</view>
</template>

<script>
	let providerList = []
	import payPop from "@/pagesC/components/payPop";

	export default {
		components: {
			payPop
		},


		data() {
			return {
				applys: {},
				industrys: {},
				isPayPopShow: false,
				wechatMiniProgram: 0,
				h5: 0,
			}
		},
		computed: {
			numList() {
				if(this.applys.shop_is_earnest == '1'){
					return [{
						name: this.$t('申请')
					}, {
						name: this.$t('等待审核')
					}, {
						name: this.$t('缴纳保证金')
					}, {
						name: this.$t('等待开通')
					}, {
						name: this.$t('成功开通')
					}, ]
				}else{
					return [{
						name: this.$t('申请')
					}, {
						name: this.$t('等待审核')
					}, {
						name: this.$t('等待开通')
					},{
						name: this.$t('成功开通')
					}, ]
				}
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: this.$t('入驻流程')
			});
			// #ifdef MP-WEIXIN
			this.wechatMiniProgram = 1;
			// #endif
			//#ifdef H5
			this.h5 = 1;
			//#endif
		},
		onShow() {
			this.getapplystatus()
		},
		onPullDownRefresh() {
			this.getapplystatus()
		},
		methods: {
			getapplystatus() {
				this.$http.getapplystatus().then(res => {
					// console.log(res)
					if (res.status == 200) {
						this.applys = res.data
						this.industrys = res.data.industrys
						this.$refs.payPop.payModel = false
						uni.stopPullDownRefresh()
					}
				})
			},
			openPayPop() {
				this.$refs.payPop.payModel = true;
			},
			async crosspay() {
				const ref = this.$refs.payPop
				let orderInfo;
				try {
					orderInfo = await this.getorderzhifu(ref.payType);
				} catch (e) {
					this.$toast(this.$t('支付失败'))
				}
				console.log("-> orderInfo", orderInfo);
				ref.payinfos = await orderInfo.data.infos
				ref.crosspay()
				this.$refs.payPop.payModel = false;
			},
			/**
			 * 支付保证金
			 */
			getorderzhifu(type) {
				 
				
				const data = {
					zf_type: type,
					wechat_miniprogram: this.wechatMiniProgram,
					h5: this.h5
				}
				if (this.wechatMiniProgram === 1) {
					data.xcx_openid = uni.getStorageSync('xcxOpenid')
				}
				return new Promise((resolve, reject) => {
					this.$http.getorderzhifu(data).then(res => {
						if (res.status == 200) {
							resolve(res)
						} else {
							reject(res)
						}
					})
				})

			},

		},
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #fff;
		padding-top: 30upx;
		height: 100%;
	}

	.sett-status {
		padding-left: 30upx;
		margin-top: 30upx;

		font-size: 26upx;
	}

	.u-p-25 {
		padding: 25upx;
	}

	.u-m-20 {
		margin: 20upx;
	}

	.settled {
		background-color: #fff;
		padding: 17upx 0 30upx 0;
		margin: 20upx 0;

		.son {
			color: #FA3F3F;
			font-size: 28upx;
			padding-left: 24upx;
			display: flex;
		}

		.son-list {
			height: 98upx;
			line-height: 98upx;
			color: #333;
			font-size: 28upx;
			padding: 0 24upx;
			border-bottom: 1upx solid rgba(249, 249, 249, 1);
		}
	}
</style>
